$(function() {
	var result1 = window.matchMedia('(min-width:1200px)');
	var result3 = window.matchMedia('(max-width:768px)');
	if(result1.matches) {
		header()
		active();
	}
	if(result3.matches) {
		header_two()
	}
	//	active();
	mydate();

})
//var result1 = window.matchMedia('(min-width:1200px)');
//  var result2 = window.matchMedia('(min-width:992px)');

//    if(result1.matches) {
//          console.log("大屏幕(>=1200)");
//      }else if(result2.matches){
//          console.log("中等屏幕(>=992&<=1200)");
//      }else if(result3.matches){
//          console.log("小屏幕(>=768&<=992)");
//      }else{
//          console.log("超小屏幕(<=768)");
//      }
function header() {
	$(".m-r115 li:nth-of-type(2)").hover(function() {
		$(".navbar-default").css("border-color", "#1568a5")
		$(this).children("span").css("display", "inline-block")
		$(".header-hover").css("height", "280px")
		//$(".header-hover")
		$(".header-hover ul li").css("display", "flex");
	}, function() {

		if($(".m-r115 li:nth-of-type(2)").attr("data-ison") == "true") {
			$(".m-r115 li:nth-of-type(2)").children("span").css("display", "inline-block")
			$(".header-hover").css("height", "0")
			$(".navbar-default").css("border-color", "#e7e7e7")
		} else {
			$(".header-hover").css("height", "0")
			$(".navbar-default").css("border-color", "#e7e7e7")
			$(this).children("span").css("display", "none")
		}

	})
	$(".header-hover").hover(function() {
		$(".navbar-default").css("border-color", "#1568a5")
		$(this).children("span").css("display", "inline-block")
		$(".header-hover").css("height", "280px")
		$(".header-hover ul li").css("display", "flex");
	}, function() {
		if($(".m-r115 li:nth-of-type(2)").attr("data-ison") == "true") {
			$(".m-r115 li:nth-of-type(2)").children("span").css("display", "inline-block")
			$(".header-hover").css("height", "0")
			$(".navbar-default").css("border-color", "#e7e7e7")
		} else {
			$(".header-hover").css("height", "0")
			$(".navbar-default").css("border-color", "#e7e7e7")
			$(".m-r115 li:nth-of-type(2)").children("span").css("display", "none")
		}

	})
	$(".header-hover ul li").hover(function() {
		$(".navbar-default").css("border-color", "#1568a5")
		var lindex = $(this).index();
		$(".m-r115 li").eq(1).children("span").css("display", "inline-block");
	}, function() {
		$(".navbar-default").css("border-color", "#e7e7e7")
		var lindex = $(this).index();
		$(".m-r115 li").eq(1).children("span").css("display", "inline-block");
	})
	$(document).mousemove(function(e) {

		if($(".header-hover").css("height") == "280px") {
			if(e.pageY > 371) {

			}
		}

	})

}

function header_two() {
	$(".m-r115 li i").on("touchstart", function() {
		if($(".phone-list").attr("data-l") == "true") {
			$(".phone-list").css("height", "0px");
			$(".phone-list").css("border-top", "0px solid gainsboro");
			$(this).addClass("fa-caret-down")
			$(this).removeClass("fa-caret-up")
			$(".phone-list").attr("data-l", "false");

		} else {
			$(".phone-list").css("height", "180px");
			$(".phone-list").css("border-top", "1px solid gainsboro");
			$(this).removeClass("fa-caret-down")
			$(this).addClass("fa-caret-up")
			$(".phone-list").attr("data-l", "true");
		}

	})
}

function active() {
	for(var i = 0; i <= 5; i++) {
		if($(".m-r115 li").eq(i).attr("data-ison") == "true") {
			$(".m-r115 li").eq(i).children("span").css("display", "inline-block")
		}
	}
}

function mydate() {
	var myDate = new Date();
	var year = myDate.getFullYear();
	var month = myDate.getMonth() + 1;
	var today = myDate.getDate();
	$(".leftText-date").html("<span>" + year + "." + month + "." + today + "</span>")
}

var btn = $("#returnTop")
$(window).scroll(function() {
	var inith = $(document).scrollTop()
	if(inith >= 500) {
		btn.css("display", "flex")
	} else {
		btn.css("display", "none")
	}

});
btn.on("click", function() {
	var time = setInterval(function() {
		var h = $(document).scrollTop()
		if(h > 0) {
			var hLast = h - 500
			$(document).scrollTop(hLast)
		} else if(h <= 0) {
			clearInterval(time);
		}
	}, 20)

})
//banner msg
var swiperData = {
	aviation: {
		swiperId: "#a-swiper",
		swiperMsg: {
			direction: 'horizontal',
			loop: true,
			slidesPerView: 4,
			navigation: {
				nextEl: '.b-right',
				prevEl: '.b-left',
			},
		}
	},
	index_one: {
		swiperId: "#ztbanner",
		swiperMsg: {
			direction: 'horizontal',
			loop: true,
			speed: 300,
			autoplay: {
				delay: 2000,
				disableOnInteraction: false
			},
			navigation: {
				nextEl: '.bz-right',
				prevEl: '.bz-left',
			},
			on: {
				slideChangeTransitionEnd: function() {
					var realIndex = this.realIndex + 1
					var imagesLoaded = this.slides.length - 2
					if(realIndex < 10) {
						realIndex = "0" + realIndex
					}
					if(imagesLoaded < 10) {
						imagesLoaded = "0" + imagesLoaded
					}
					$(".yl-num").html("<span>" + realIndex + "&nbsp;-&nbsp;" + imagesLoaded + "</span>")
					newsImg_one(realIndex, imagesLoaded)
				},
			},
		}
	},
	index_two: {
		swiperId: ".newswiper",
		swiperMsg: {
			loop: true,
			speed: 300,
			autoplay: {
				delay: 5000,
				disableOnInteraction: false
			},
			navigation: {
				nextEl: '.yl-right',
				prevEl: '.yl-left',
			},
			on: {
				slideChangeTransitionEnd: function() {
					var realIndex = this.realIndex + 1
					var imagesLoaded = this.slides.length - 2
					newsImg_two(realIndex, imagesLoaded)
				},
			},
		}
	},
	index_three: {
		swiperId: ".newswiper-two",
		swiperMsg: {
			loop: true,
			speed: 300,
			autoplay: {
				delay: 5000,
				disableOnInteraction: false
			},

			// 如果需要前进后退按钮
			navigation: {
				nextEl: '.yl-right',
				prevEl: '.yl-left',
			},
			on: {
				slideChangeTransitionEnd: function() {
					var realIndex = this.realIndex + 1
					var imagesLoaded = this.slides.length - 2
					newsImg_three(realIndex, imagesLoaded)
				},
			},
		}

	}
}